package com.itheima2;

import java.io.File;
import java.io.IOException;

public class Work01 {
    public static void main(String[] args) throws IOException {
       File file = new File("D:\\itcast\\java.txt");
        System.out.println(file.createNewFile());
        file.delete();

        System.out.println("--------");
       File file1 = new File("D:\\itcast\\javase");
        boolean mkdirs = file1.mkdirs();
        System.out.println(mkdirs);
        System.out.println("--------");

        File file2 = new File("D:\\itcast\\Javaee");
        System.out.println(file2.mkdirs());
        deleteDir(file2);
        System.out.println("--------");
       File file3 = new File("D:\\itcast\\heima\\hello.txt");
        System.out.println(file3.mkdirs());
        File file4 = new File(file3.getParentFile(),"world.txt");
        System.out.println( file3.renameTo(file4));
        System.out.println("--------");





    }
    public static void deleteDir(File src){
        File[] files =src.listFiles();
        for (File file : files) {
            if (file.isFile()){
                file.delete();
            }else{
                deleteDir(file);
            }

        }
        src.delete();
    }
}
